package com.yh.ldzl.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.yh.ldzl.domain.QcIndex;
import com.yh.ldzl.service.QcDefectService;
import com.yh.ldzl.service.QcIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 检测项管理Controller
 *
 * @author ruoyi
 * @date 2024-08-18
 */
@RequestMapping("/qc/qcIndex")
@RestController
public class QcIndexController {
    @Autowired
    private QcIndexService qcIndexService;

    //查询检测项列表
    @PostMapping("/selectQcIndexList")
    @Log(title = "查询检测项列表", businessType = BusinessType.INSERT)
    public IPage<QcIndex> selectQcIndexList(@RequestParam(name = "index_code",required = false) String index_code,
                                            @RequestParam(name = "index_name",required = false)String index_name,
                                            @RequestParam(name = "index_type", required = false)String index_type,
                                            @RequestParam(required = false, defaultValue = "1") Integer pageNum, // 设置默认值
                                            @RequestParam(required = false, defaultValue = "10") Integer pageSize)

    {
        System.out.println("index_code:"+index_code);
        return qcIndexService.selectQcIndexList(index_code,index_name,index_type,pageNum,pageSize);
    }

    //添加检测项
    @PostMapping("/insertQcIndex")
    @Log(title = "添加检测项", businessType = BusinessType.INSERT)
    public boolean insertQcIndex(@RequestBody QcIndex qcIndex){
        return qcIndexService.insertQcIndex(qcIndex);
    }
    //修改检测项
    @PostMapping("/updateQcIndex")
    @Log(title = "修改检测项", businessType = BusinessType.INSERT)
    public boolean updateQcIndex(@RequestBody QcIndex qcIndex){
        return qcIndexService.updateQcIndex(qcIndex);
    }

    //删除检测项
    @PostMapping("/deleteQcIndex")
    @Log(title = "删除检测项", businessType = BusinessType.INSERT)
    public boolean deleteQcIndex(@RequestBody List<Long> ids){
        return qcIndexService.deleteQcIndex(ids);
    }




}
